(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.lookup.sitetplRoleController', sitetplRoleController);
	sitetplRoleController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 
	                                     'validatorConfig', 'authService', 'ajaxServiceFactory' ];
	function sitetplRoleController($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, 
			validatorConfig, authService, ajaxServiceFactory) {
		var ctrl = this, log = $scope.loggerFactory.getLogger("sitetplRoleLookup"), ajaxService = ajaxServiceFactory.buildAjaxService({
		});
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		
		ctrl.ok = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['ok'] || dialogsModule.btnCallback['ok'](ctrl.selectedRows) !== false) {
				$uibModalInstance.close();
			}
		};
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			ctrl.innerGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.fieldCfg.tableConfigs.table, rowSelectionChanged);
			ctrl.innerGridOptions.data = 'vm.sitetplRoles';
			function rowSelectionChanged(eventRow, selectedRows) {
				ctrl.selectedRows = selectedRows;
			}
			
			//
			ctrl.sitetplRoles = ctrl.dialogsModule.params.sitetplRoles;
		};

		
	}
})(angular);
